package controller

import (
	"gin/CloudRestaurant/service"
	"gin/CloudRestaurant/tool"
	"github.com/gin-gonic/gin"
)

type UserController struct {

}

func (uc *UserController) Router(router *gin.Engine)  {
	// 登录
	router.GET("/api/login/:username/:password",uc.login)
}

func (uc *UserController)login(context *gin.Context) {
	username := context.Param("username")
	password := context.Param("password")

	us := service.UserService{}
	result := us.Login(username,password,context)
	if result == ""{
		tool.Success(context,"账号或者用户名出错")
		return
	}
	//context.Header("token","123kjm ,m")
	tool.Success(context,result)
	return

}